package com.example.springboot2redisclusterdemo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chaird
 * @create 2022-07-28 23:27
 */
@RestController
public class DemoController {
    @Autowired
    private RedisTemplate redisTemplate;
    @GetMapping("/add")
    public String redis() {
        redisTemplate.opsForValue().set("k1", "v1");
        return "ok";
    }

    @GetMapping("/get")
    public Object get() {
        Object o = redisTemplate.opsForValue().get("k1");
        return o;
    }
}


